package it.avantsoft.ls.peer.message;

import java.io.DataOutputStream;
import java.io.IOException;

public class ReconnectMessage extends PeerMessage {
    private String peerId;
    private String exGroupLeaderId;

    public ReconnectMessage(DataOutputStream out, String peerId, String exGroupLeaderId) {
        super(out);
        this.peerId = peerId;
        this.exGroupLeaderId = exGroupLeaderId;
    }

    public boolean send() {
        boolean sent = false;
        try {
            writeByte(RECONNECT);
            writeUTF(peerId);
            writeUTF(exGroupLeaderId);
            flush();
            sent = true;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return sent;
    }

    public String toString() {
        return "ReconnectMessage{" +
                "peerId='" + peerId + '\'' +
                ", exGroupLeaderId='" + exGroupLeaderId + '\'' +
                '}';
    }
}
